package com.guoxiaochen.springboot.service;

import com.guoxiaochen.springboot.dao.UserDao;
import com.guoxiaochen.springboot.entity.User;
import org.springframework.data.domain.Example;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.repository.query.FluentQuery;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Optional;
import java.util.function.Function;

@Service
public class UserServiceImp implements UserService{


    @Resource
    private UserDao ud;

    public User findUserByUsernameAndPassword(String name, String password) {
        return ud.findUserByUsernameAndPassword(name,password);
    }


    public String addUser(User u) {

        User user = ud.verifyAccount(u.getUsername());
        if (user != null) {
            return "注册失败！";
        }else{
                if(ud.save(u) != null){
                    return "注册成功！";
                }
                else{
                    return "注册失败！";
                }
        }


    }
}
